package pers.jing.android.helper.model

/**
 * 华为
 */
const val BRAND_HUAWEI = "HUAWEI"
/**
 * 荣耀
 */
const val BRAND_HONOR = "HONOR"
const val UNKNOWN = "unknown"

/**
 * 小米
 */
const val BRAND_XIAOMI = "Xiaomi"


/**
 * vivo
 */
const val BRAND_VIVO = "vivo"


class DeviceInfo(val serialId: String, val properties: Map<String, String>) {

    /**
     * 品牌
     */
    fun getDeviceBrand(): String {
        return properties["ro.product.brand"]?:UNKNOWN
    }


    /**
     * 设备名称
     */
    fun getDeviceName(): String {
        val brand = getDeviceBrand()
        var key = if (BRAND_HUAWEI.equals(brand, true)
            || BRAND_HONOR.equals(brand, true)) {
            "ro.config.marketing_name"
        } else if (BRAND_XIAOMI.equals(brand, true)) {
            "ro.product.marketname"
        } else if (BRAND_VIVO.equals(brand, true)) {
            "ro.vivo.market.name"
        } else {
            "ro.product.name"
        }
        return properties[key]?:UNKNOWN
    }

    /**
     * 获取设备型号
     */
    fun getDeviceModel(): String {
        return properties["ro.product.model"]?:UNKNOWN
    }

    /**
     * Android系统版本
     */
    fun getAndroidOSVersion(): String {
        return properties["ro.build.version.release"]?:UNKNOWN
    }

}